package com.power.service.impl;

import com.power.common.Contants;
import com.power.dao.InformationDao;
import com.power.dao.impl.InformationDaoImpl;
import com.power.ov.ResultData;
import com.power.service.InformationService;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

/**
 * Created with IntelliJ IDEA.
 * User: 朱雄
 * Date: 2020/10/09 11:29
 * Description:
 * Version: V1.0
 */

public class InformationServiceImpl implements InformationService {
    InformationDao informationDao=new InformationDaoImpl();
    @Override
    public ResultData eliminateAll() throws SQLException {
        ResultData resultData=new ResultData();
        List<Map<String,Object>> list=informationDao.eliminateAll();
        resultData.setCode(Contants.SUCCESS);
        resultData.setMsg("查询成功");
        resultData.setData(list);
        return resultData;
    }

    @Override
    public ResultData eliminateByAccount(String account) throws SQLException {
        ResultData resultData=new ResultData();
        List<Map<String,Object>> list=informationDao.eliminateByAccount(account);
        if (list.size()>0){
            resultData.setCode(Contants.SUCCESS);
            resultData.setMsg("查询成功");
            resultData.setData(list);
        }else {
            resultData.setCode(Contants.FAILURE);
            resultData.setMsg("没有"+account+"消缺员");
        }
        return resultData;
    }

    @Override
    public ResultData inspectionAll() throws SQLException {
        ResultData resultData=new ResultData();
        List<Map<String,Object>> list=informationDao.inspectionAll();
        resultData.setCode(Contants.SUCCESS);
        resultData.setMsg("查询成功");
        resultData.setData(list);
        return resultData;
    }

    @Override
    public ResultData inspectionByAccount(String account, String defect) throws SQLException {
        ResultData resultData=new ResultData();
        List<Map<String,Object>> list=informationDao.inspectionByAccount(account,defect);
        if (list.size()>0){
            resultData.setCode(Contants.SUCCESS);
            resultData.setMsg("查询成功");
            resultData.setData(list);
        }else{
            resultData.setCode(Contants.FAILURE);
            resultData.setMsg("没有数据哦");
        }
        return resultData;
    }
}
